﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

using DuelQuizz.contract;
using DuelQuizz.DuelQuizzServiceReference;
using DuelQuizzServer;

namespace DuelQuizz
{
    /// <summary>
    /// Logique d'interaction pour Categories.xaml
    /// </summary>
    public partial class Categories : UserControl
    {
        private User user;
        public Categories(User user)
        {
            List<Category> g = AppServices.getDuelQuizzServices().getAllCategories().ToList();
            InitializeComponent();

            this.user = user;
            this.cbCategories.DisplayMemberPath = "name";
            this.cbCategories.ItemsSource = g;
            this.cbCategories.SelectedIndex = 0;
        }

        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            // Call category web service
            Continue();
        }

        private void Continue()
        {
            // Call next window
            Quiz quiz = new Quiz(AppServices.getDuelQuizzServices().getCategory(((Category)cbCategories.SelectedItem).id), 3, user);

            MainWindow.changeWindows(quiz);
        }
    }
}
